<div class="app-table">
  <nz-table #nzTable [nzData]="triggerList" [(nzPageSize)]="pageSize" [(nzPageIndex)]="pageNo" nzShowSizeChanger
    [nzTotal]="totalCount" [nzShowTotal]="rangeTemplate" [nzLoading]="isLoading" [nzFrontPagination]="false"
    [nzNoResult]="noResult" (nzPageIndexChange)="getTriggerList(groupId, functionId)"
    (nzPageSizeChange)="getTriggerList(groupId, functionId)" [nzShowPagination]="totalCount>10" class="table-fixed">
    <thead>
      <tr>
        <th nzWidth="2.5rem">ID/名称</th>
        <th>状态</th>
        <th>触发版本/别名</th>
        <th *ngIf="!isDetail">所属应用</th>
        <th *ngIf="!isDetail">所属函数</th>
        <th>触发器类型</th>
        <th nzWidth="2rem">更新时间</th>
        <th nzWidth="1.6rem">操作</th>
      </tr>
    </thead>
    <tbody>
      <tr *ngFor="let data of nzTable.data; let i = index;trackBy: trackById">
        <!-- nzLeft="0px" -->
        <td>
          <p nz-popover [nzPopoverContent]="data.id" class="ellipsis">
            <a  *ngIf="data.type !== 'apig'" style="color: #5a5a5a;"
            href="javascript:void(0);" (click)="linkToAPIDetail(data)">
            <in-acl-btn [inActions]="data?.resActions" inAction="GetTrigger" inLabel="{{data.id}}"> 
              <span class="ellipsis before-opt">{{data.id}}</span>
            </in-acl-btn>
            </a>
            <a *ngIf="data.type === 'apig'" href="javascript:void(0);" (click)="linkToAPIDetail(data)">
              <span class="ellipsis before-opt">{{data.id}}</span>
            </a>
            <a class="td-opt" ngxClipboard [cbContent]="data?.id" (cbOnSuccess)="successFun()">
              <i class="iconfont icon-gongnengtubiao-fuzhicopy"></i>
            </a>
          </p>
          <p class="ellipsis">
            <span nz-popover [nzPopoverContent]="data.name">{{data.name}}</span>
          </p>
        </td>
        <td [innerHtml]="data.isEnable | status:'ifcs-trigger' | async">{{data.isEnable}}</td>
        <td>{{data.targetType == 1 ? "版本" : "别名"}}: {{data.targetName || '--'}}</td>
        <td *ngIf="!isDetail">
          <p class="ellipsis" nz-popover [nzContent]="data?.groupDisplayName">
            <span>{{data?.groupDisplayName || '--'}}</span>
          </p>
        </td>
        <td *ngIf="!isDetail">
          <p class="ellipsis" nz-popover [nzContent]="data.funcName">
            <span>{{data.funcName || '--'}}</span>
          </p>
        </td>
        <td [ngSwitch]="data.type">
          <span *ngSwitchCase="'oss'">对象存储触发器</span>
          <span *ngSwitchCase="'timer'">定时触发器</span>
          <span *ngSwitchCase="'apig'">API 网关触发器</span>
          <span *ngSwitchCase="'http'">HTTP 触发器</span>
          <span *ngSwitchDefault>--</span>
        </td>
        <td>{{(data.updateTime| date: 'yyyy-MM-dd HH:mm:ss') || '--'}}</td>
        <td class="table-opt">
          <in-acl-source [inGroup]="'tableAction'" [inService]="'fcs'" [inResourceType]="'fcs-trigger'"
                [inActions]="['GetTrigger','UpdateTrigger','DeleteTrigger']" [inInstanceId]="data?.id" [inResourceAccountId]="data?.accountId" [inTrData]="data" [inIsLast]="i===nzTable.data.length-1">
        <in-acl-btn [inActions]="data?.resActions" inAction="UpdateTrigger" inLabel="配置"> 
          <a (click)="editTrigger(data)">配置</a>
        </in-acl-btn>
        <in-acl-btn [inActions]="data?.resActions" inAction="DeleteTrigger" inLabel="删除"> 
          <a (click)="deleteTrigger(data)">删除</a>
        </in-acl-btn>
          <a *ngIf="data?.type === 'apig' || data?.type === 'http'" (click)="accessInvokeUrl(data)">URL</a>
          </in-acl-source>
        </td>
      </tr>
    </tbody>
    <ng-template #noResult>
      <ng-container *ngIf="!hasInputValue">
        <table-no-result-add title="抱歉，你还没有触发器！"  (actionClick)="createTrigger()" inLabel="去创建" inAction="CreateTrigger" [inAclActions]="inActions">
        </table-no-result-add>
      </ng-container>
      <ng-container *ngIf="hasInputValue">
        <table-no-result-search></table-no-result-search>
      </ng-container>
    </ng-template>
    <ng-template #rangeTemplate let-range="range" let-total>
      共{{total}}条
    </ng-template>
  </nz-table>
</div>